package com.gxa.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.utils.TPage;
import com.gxa.common.utils.Query;
import com.gxa.modules.sys.entity.User01;
import com.gxa.modules.sys.mapper.UserMapper01;
import com.gxa.modules.sys.service.UserService01;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class UserService01Impl extends ServiceImpl<UserMapper01, User01> implements UserService01 {


    @Override
    public User01 queryByUsername(String username) {
        User01 user = baseMapper.selectOne(new QueryWrapper<User01>().eq("user_name", username));
        return user;
    }

    @Override
    public User01 queryByUsername01(String username) {
        User01 user = baseMapper.queryByUsername01(username);
        return user;
    }

    @Override
    public TPage queryByPage01(Map<String, Object> params) {
        IPage<User01> page = this.page(new Query<User01>().getPage(params));
        TPage pageUtils = new TPage(page);
        return pageUtils;
    }

    @Override
    public TPage queryByPage02(Map<String, Object> params) {
        String username = (String)params.get("username");
        String id = (String)params.get("id");


        IPage<User01> page = this.page(new Query<User01>().getPage(params),
                new QueryWrapper<User01>().like(StringUtils.isNotEmpty(username),"user_name",username)
                        .eq(StringUtils.isNotEmpty(id),"id",id)
                );
        return new TPage(page);
    }



}
